package com.ncp.servlet.registerlogin;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.ncp.model.biz.registerlogin.LoginBiz;

public class DelImgInTomcat extends HttpServlet {

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
       
		this.doPost(request, response);
		
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html;charset=utf-8");
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");		
		HttpSession session = request.getSession(true);
		if(session==null){
			
			request.getRequestDispatcher("index.jsp").forward(request, response);
		}
		else{
		String path1 = request.getServerName();
		String path2 = request.getRealPath(path1);
		int n=path2.lastIndexOf("\\");
		String S_realPath=path2.substring(0,n);
		String realPath =S_realPath+"\\"; 
		boolean b1 = false;
		int UserID = Integer.parseInt(session.getAttribute("userID").toString());
		LoginBiz mbpb= new LoginBiz();
		b1=mbpb.delImgsInTomcatBef(UserID, realPath);
		
		request.getRequestDispatcher("pages/registerlogin/modifyregister.jsp").forward(request, response);
	}
	}
}
